package com.studentmanage.manage_class.controller;

import com.studentmanage.api.clas.ClassControllerApi;
import com.studentmanage.framework.domain.base.Clas;
import com.studentmanage.framework.domain.base.Learn;
import com.studentmanage.framework.domain.common.response.QueryResult;
import com.studentmanage.framework.domain.common.response.ResponseResult;
import com.studentmanage.framework.domain.common.response.ResponseValue;
import com.studentmanage.manage_class.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/class")
public class ClassController implements ClassControllerApi {
    @Autowired
    private ClassService classService;

    @Override
    @PostMapping("/add")
    public ResponseResult addClass(@RequestBody Clas clas) {
        return classService.addClass(clas);
    }

    @Override
    @GetMapping("/get/{id}")
    public ResponseValue<Clas> findByCollegeId(@PathVariable("id") String id) {
        return classService.findByCollegeId(id);
    }

    @Override
    @GetMapping("/get/list")
    public QueryResult<Clas> findListForStu() {
        return classService.findListForStu();
    }

    @Override
    @PostMapping("/edit")
    public ResponseResult updateClass(@RequestBody Clas clas) {
        return classService.updateClass(clas);
    }

    @GetMapping("/learn/get/{id}")
    public ResponseValue<Learn> findLearnByCollegeId(@PathVariable("id") String id) {
        return classService.findLearnByCollegeId(id);
    }
}
